#include "Method.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Method_classType = NULL;
VTable* Method_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Type returns() */
Type* Method_returns(Method* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.returns not implemented yet"));
}


/* Param[] params() */
List* Method_params(Method* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.params not implemented yet"));
}


/* Func func() */
Func* Method_func(Method* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.func not implemented yet"));
}


/* Obj? callList(Obj?[]? args) */
NullableObj Method_callList(Method* self, List* args)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.callList not implemented yet"));
}


/* Obj? callOn(Obj? target, Obj?[]? args) */
NullableObj Method_callOn(Method* self, NullableObj target, List* args)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.callOn not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_0(Method* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_1(Method* self, NullableObj a)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_2(Method* self, NullableObj a, NullableObj b)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_3(Method* self, NullableObj a, NullableObj b, NullableObj c)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_4(Method* self, NullableObj a, NullableObj b, NullableObj c, NullableObj d)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_5(Method* self, NullableObj a, NullableObj b, NullableObj c, NullableObj d, NullableObj e)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_6(Method* self, NullableObj a, NullableObj b, NullableObj c, NullableObj d, NullableObj e, NullableObj f)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call_7(Method* self, NullableObj a, NullableObj b, NullableObj c, NullableObj d, NullableObj e, NullableObj f, NullableObj g)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/* Obj? call(Obj? a, Obj? b, Obj? c, Obj? d, Obj? e, Obj? f, Obj? g, Obj? h) */
NullableObj Method_call(Method* self, NullableObj a, NullableObj b, NullableObj c, NullableObj d, NullableObj e, NullableObj f, NullableObj g, NullableObj h)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Method.call not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Method_initType(void)
{
  if (Method_classType == NULL)
  {
    Type* baseType = Slot_initType();
    VTable* vtable = Method_initVTable();
    Type* type = Type_new("Method", baseType, vtable, sizeof(Method), sizeof(MethodVTable));
    Type_registerMethodImplementation(type, "call", Method_call_0, 0);
    Type_registerMethodImplementation(type, "call", Method_call_1, 1);
    Type_registerMethodImplementation(type, "call", Method_call_2, 2);
    Type_registerMethodImplementation(type, "call", Method_call_3, 3);
    Type_registerMethodImplementation(type, "call", Method_call_4, 4);
    Type_registerMethodImplementation(type, "call", Method_call_5, 5);
    Type_registerMethodImplementation(type, "call", Method_call_6, 6);
    Type_registerMethodImplementation(type, "call", Method_call_7, 7);
    Type_registerMethodImplementation(type, "call", Method_call, 8);
    Type_registerMethodImplementation(type, "callList", Method_callList, 1);
    Type_registerMethodImplementation(type, "callOn", Method_callOn, 2);
    Type_registerMethodImplementation(type, "func", Method_func, 0);
    Type_registerMethodImplementation(type, "params", Method_params, 0);
    Type_registerMethodImplementation(type, "returns", Method_returns, 0);
    Method_classType = type;
    Method_initStatic();
  }
  return Method_classType;
}


VTable* Method_initVTable(void)
{
  if (Method_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(MethodVTable));
    memcpy(vtable, Slot_initVTable(), sizeof(SlotVTable));
    Method_classVTable = vtable;
  }
  return Method_classVTable;
}


void Method_initStatic(void)
{
}
